;;; early-init.el --- Early initialization. -*- lexical-binding: t -*-

;;; Commentary:

;; Emacs 27 introduces early-init.el, which is run before init.el,
;; before package and UI initialization happens.

;;; Code:

;; set same background-color to theme, to prevent screen blink
(when (equal (substring (user-login-name) 0 3) "cor")
  (add-to-list 'default-frame-alist '(background-color . "black")))

;; garbage-collection
(setq gc-cons-threshold (max most-positive-fixnum (* 1024 1024 1024)))
;; when idle for 10 seconds or when Emacs is unfocused.
(run-with-idle-timer 10 t #'garbage-collect)
;; Don’t compact font caches during GC.
(setq inhibit-compacting-font-caches t)

;; Package initialize occurs automatically, before `user-init-file' is
;; loaded, but after `early-init-file'. We handle package
;; initialization, so we must prevent Emacs from doing it early!
(setq package-enable-at-startup nil)

;; `use-package' is builtin since 29.
;; It must be set before loading `use-package'.
(setq use-package-enable-imenu-support t)

;; In noninteractive sessions, prioritize non-byte-compiled source files to
;; prevent the use of stale byte-code. Otherwise, it saves us a little IO time
;; to skip the mtime checks on every *.elc file.
(setq load-prefer-newer noninteractive)

;; Explicitly set the prefered coding systems to avoid annoying prompt
;; from emacs (especially on MsWin)
(prefer-coding-system 'utf-8)
(when (eq system-type 'gnu/linux)
  (set-default-coding-systems 'utf-8))

;; Inhibit resizing frame
(setq frame-inhibit-implied-resize t)

;; Faster to disable these here (before they've been initialized)
(push '(menu-bar-lines . 0) default-frame-alist)
(push '(tool-bar-lines . 0) default-frame-alist)
(push '(vertical-scroll-bars) default-frame-alist)
(when (featurep 'ns)
  (push '(ns-transparent-titlebar . t) default-frame-alist))

(provide 'early-init)

;;; early-init.el ends here
